package com.xingxuecn.limit.web.action;

import com.opensymphony.xwork2.ActionSupport;
import com.xingxuecn.limit.common.model.TreeNode;
import com.xingxuecn.limit.common.utils.ResponseUtils;
import com.xingxuecn.limit.service.HeaderService;
import com.xingxuecn.limit.service.impl.HeaderServiceImpl;

import org.apache.struts2.ServletActionContext;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

/**
 * @author Kris at 2018/9/5 14:37
 */
public class IndexAction extends ActionSupport {
    private HeaderService headerService = new HeaderServiceImpl();


    public String index(){
        return SUCCESS;
    }


    
    public String loadHeaderTree() throws SQLException {
        HttpServletResponse response = ServletActionContext.getResponse();
        List<TreeNode> treeNodeList = headerService.headerTree();
        ResponseUtils.writeJson(treeNodeList,response);
        return null;
    }

}
